package com.cq.hd.merchant.controller;

import com.cq.hd.common.annotation.MerchantLoginUser;
import com.cq.hd.common.entity.MerchantAppLoginUser;
import com.cq.hd.common.response.Result;
import com.cq.hd.common.response.ResultGenerator;
import com.cq.hd.merchant.biz.StatisticsBiz;
import com.cq.hd.merchant.dto.CoreDataStatisticsDto;
import com.cq.hd.merchant.dto.CoreDataTrendStatisticsDto;
import com.cq.hd.merchant.vo.CoreDataStatisticsVo;
import com.cq.hd.merchant.vo.CoreDataTrendStatisticsVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

@RestController
@RequestMapping("/statistics")
@Api(tags = "统计相关接口")
public class StatisticsController extends BaseController {

    @Autowired
    private StatisticsBiz statisticsBiz;

    @ApiOperation(value = "核心数据统计")
    @ApiResponse(response = CoreDataStatisticsVo.class, code = 200, message = "接口返回对象参数")
    @GetMapping("/getCoreData")
    public Result<CoreDataStatisticsVo> getCoreData(@ApiIgnore @MerchantLoginUser MerchantAppLoginUser merchantAppLoginUser,
                                                   CoreDataStatisticsDto allDataStatisticsDto) {
        allDataStatisticsDto.setMerchantId(merchantAppLoginUser.getMerchantId());
        return ResultGenerator.success(statisticsBiz.getCoreData(allDataStatisticsDto));
    }

    @ApiOperation(value = "核心数据趋势统计")
    @ApiResponse(response = CoreDataTrendStatisticsVo.class, code = 200, message = "接口返回对象参数")
    @GetMapping("/getCoreDataTrend")
    public Result<List<CoreDataTrendStatisticsVo>> getCoreDataTrend(@ApiIgnore @MerchantLoginUser MerchantAppLoginUser merchantAppLoginUser,
                                                                   CoreDataTrendStatisticsDto allDataTrendStatisticsDto) {
        allDataTrendStatisticsDto.setMerchantId(merchantAppLoginUser.getMerchantId());
        return ResultGenerator.success(statisticsBiz.getCoreDataTrend(allDataTrendStatisticsDto));
    }

}
